import sqlite3
import pandas as pd

# 创建连接
conn = sqlite3.connect('data/database.db')

# 创建表
cursor = conn.cursor()
cursor.execute('''
create table if not exists cat(
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    age INTEGER NOT NULL 
)
''')

# 插入示例数据
cursor.execute("INSERT INTO cat (name,age) VALUES ('kitty',2)")
cursor.execute("INSERT INTO cat (name,age) VALUES ('Tom',3)")
cursor.execute("INSERT INTO cat (name,age) VALUES ('Jerry',1)")

conn.commit()

# 读取数据
df = pd.read_sql('select * from cat',conn)
print(df)
print("传参")
df1 = pd.read_sql('select * from cat where age > ?',conn,params=(1,))
print(df1)